home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Amiga Amateur Radio User Group / AARUG UK #45 (199x)(Amiga Amateur Radio User Group UK)(PD)[WB][G4DCV].zip / AARUG UK #45 (199x)(Amiga Amateur Radio User Group UK)(PD)[WB][G4DCV].adf / SnoopDos.doc < prev    next >
Text File  |  1992-12-16  |  16KB  |  330 lines

  1.  
  2.                  SnoopDos 1.7 -- Monitors AmigaDOS function calls
  3.  
  4.          (C) Copyright Eddy Carroll, December 1992. Freely Distributable.
  5.  
  6.  
  7. INTRODUCTION
  8.  
  9.     Have you ever wondered why a particular program won't seem to run?
  10.     It could be looking for some special files which you've forgotten to
  11.     install in the appropriate place. SnoopDos was designed to let you
  12.     resolve situations like this, though it's probably useful for other
  13.     things too.
  14.  
  15.     For those who don't like long instruction files, simply run SnoopDos
  16.     with no options, then run a few application programs and look at the
  17.     output displayed in SnoopDos's window. Interesting, eh? For those who'd
  18.     like a more detailed explanation, read on...
  19.  
  20.     When you start SnoopDos, it opens a console window. In this window
  21.     appears details of all calls made by any program on the system to the
  22.     CurrentDir(), DeleteFile, Execute(), LoadSeg(), Lock() and Open()
  23.     functions in the AmigaDOS library. The exception (as usual) is any
  24.     program written in BCPL; this includes most of the commands in the C:
  25.     directory.
  26.  
  27.     SnoopDos will tell you about all attempts to load libraries, devices
  28.     and fonts. It will also tell you if a program looks for a specific file
  29.     (for example in S:) or a specific disk volume or directory. This can be
  30.     very useful when you're playing with new software which may require
  31.     certain fonts or other support files.
  32.  
  33.     An unexpected bonus is that since AmigaDOS environment variables are
  34.     stored as files, SnoopDos will tell you the names of any environment
  35.     variables a program tries to read; if you see references to ENV:<name>
  36.     in the SnoopDos window, then a program is trying to access an environment
  37.     variable called <name>.
  38.  
  39.  
  40. USAGE
  41.  
  42.     When you start SnoopDos, it automatically detaches itself from the CLI
  43.     and runs in the background. You can specify a number of options on the
  44.     command line, either at this time or later on by running SnoopDos again.
  45.     Each option can be given in lower case or upper case to respectively
  46.     enable or disable that setting. Alternatively, you can follow the option
  47.     by `1' or `0' which has the same effect. So, `-d' and `-d1' both enable
  48.     the "Monitor DeleteFile()" option, whereas `-d' and `-d0' both disable
  49.     that option. Without further ado, here's an explanation of each setting:
  50.  
  51.     -a  Normally, SnoopDos uses different colours when displaying messages,
  52.         to allow events to be easily distinguished from each other. You can
  53.         force SnoopDos not to use any colour by disabling this option. This
  54.         can be useful if you only have a 2-colour workbench. If SnoopDos is
  55.         sending its output to a file, it turns off this option by default
  56.         (but you can turn it back on again if you like).
  57.  
  58.     -c  When this option is enabled, SnoopDos prints details of all calls
  59.         to the CurrentDir() function. A program calls CurrentDir() when it
  60.         wants to change its current directory to somewhere else. Note that
  61.         no result is displayed for this function, since AmigaDOS does not
  62.         allow for the possibility of it ever failing.
  63.  
  64.     -d  This option allows you to see all calls to the DeleteFile() function,
  65.         which is called whenever a program wants to delete a file. This can
  66.         be useful with unknown programs, to make sure that they don't do
  67.         anything nasty (though in fairness, there are much more effective
  68.         ways for a rogue program to do damage than by deleting a few files).
  69.  
  70.     -f  When enabled, this option causes SnoopDos to print out the full
  71.         path names for files. For example, if a program's current directory
  72.         is SYS:TOOLS and it tries to open a file called FOO, then the
  73.         filename would be displayed as SYS:TOOLS/FOO. Normally, it would
  74.         just be displayed as FOO. Filenames which are so expanded are
  75.         prefixed by a `>' character. Filenames which already included a full
  76.         path specification don't have this prefix. This allows you to
  77.         determine if the calling program specified the full path or not.
  78.  
  79.     -g  This option enables or disables the monitoring of AmigaDOS's
  80.         LoadSeg() function. This is used to read in a binary loadfile and is
  81.         most commonly used for loading in libraries, devices, fonts and
  82.         handlers, and by third-party DOS shells to load in external commands.
  83.  
  84.     -i  When this option is enabled, SnoopDos will ignore any calls to
  85.         Lock() by the Shell and calls to CurrentDir() by either the Shell
  86.         or Workbench. This can reduce the amount of output by quite a
  87.         bit under Kickstart 2.0, particularly when the Shell is searching
  88.         the command path for a command and Workbench is checking up on
  89.         the mounted disk volumes (which it does once a second). This
  90.         option is enabled by default, but you can turn it off with -i0 to
  91.         see what all the fuss is about.
  92.  
  93.     -l  This option enables or disables the monitoring of AmigaDOS's Lock()
  94.         function. Programs usually call this function to see if a particular
  95.         file exists, or as a prelude to some more sophisticated operation on
  96.         the file.
  97.  
  98.     -m  This option allows SnoopDos to be activated or deactivated while
  99.         still leaving it running. It is included merely for completeness;
  100.         a much easier way to achieve the same affect is to type CTRL-D or
  101.         CTRL-E in the SnoopDos window.
  102.  
  103.     -o  This option enables or disables the monitoring of AmigaDOS's Open()
  104.         function. Whenever a program wants to open a file for reading or
  105.         writing, it calls this function.
  106.  
  107.     -s  Adds a carriage return to the end of every line output. This is
  108.         useful with some devices that expect a return to accompany every
  109.     line feed.
  110.  
  111.     -w  If several tasks try to call a particular DOS function at the same
  112.         time, SnoopDos can only handle them one at a time. Normally, what
  113.         will happen is that the other tasks speed on without waiting for
  114.         SnoopDos and you see a warning message saying that some function
  115.         calls were missed (this doesn't happen very often anyway). When the
  116.         `-w' option is enabled however, SnoopDos will make all the
  117.         different tasks queue up and take their turn.
  118.  
  119.         There is one important consequence of this: if a program tries to
  120.         access a file on a volume not currently mounted (causing AmigaDOS to
  121.         display a "Please insert volume xyzzy" requester), then SnoopDos will
  122.         print out the details about the file requested but not whether the
  123.         request succeeded or not; it can't do this until you respond to the
  124.         requester. In the meantime, other tasks may now be trying to call
  125.         AmigaDOS. For example, if you might try to pop open a new CLI with
  126.         Dmouse or PopCLI, so that you can do an ASSIGN to fake the requested
  127.         volume. All these tasks will have to wait until the original DOS
  128.         call has been completed.
  129.  
  130.         Since this can confuse things (though only for the user), the option
  131.         is disabled by default. You should only need it if you have to be
  132.         absolutely sure of catching every action made by several tasks.
  133.  
  134.     -x  This option enables or disables monitoring of Execute() calls.
  135.         Unlike most other DOS function calls, the return value from the
  136.         Execute() is NOT displayed; this is because when an Execute suceeds,
  137.         the command being executed will most likely making AmigaDOS calls of
  138.         of its own and if SnoopDos was waiting for Execute() to return, it
  139.         would skip printing these out.
  140.  
  141.         Some forms of Execute() will appear to have no associated command
  142.         to execute. This is normal, and occurs when a program redirects
  143.         command input from another file.
  144.  
  145.  
  146.     By default, Snoopdos operates as if you had started it with:
  147.  
  148.         SnoopDos -a1 -c1 -d1 -f0 -g1 -i1 -l0 -m1 -o1 -s0 -w0 -x1
  149.  
  150.     or for those who prefer to use the other command format:
  151.  
  152.         SnoopDos -a -c -d -F -g -i -L -m -o -s -w -x
  153.  
  154.     There are some additional options as well, which cause immediate
  155.     actions to be performed. These are:
  156.  
  157.     -h  Prints out a help screen for SnoopDos. Actually, typing any
  158.         unrecognised garbage after SnoopDos prints the help screen.
  159.  
  160.     -n  If you are sending SnoopDos output to a text file, it is buffered
  161.         in 8K chunks to avoid doing lots of tiny writes, which can be slow.
  162.     Using this option disables that buffering, which is convenient if
  163.     you are redirecting output to a printer or similar device.
  164.  
  165.     -q  Sends a message to the version of SnoopDos currently running telling
  166.         it to remove itself. This is one way to quit SnoopDos, the other
  167.         way being to type CTRL-C in its window.
  168.  
  169.     -r  Prints out a brief report giving all the current settings for
  170.         SnoopDos (eagle-eyed users may spot a striking resemblance between
  171.         this display and the middle section of the help screen :-). Note
  172.         that all other command line options are ignored when you use -r.
  173.  
  174.     -z  Allows you to specify an alternative output file for SnoopDos to
  175.         send messages to. The filename can follow immediately after the -z,
  176.         or you can leave a space if you like.
  177.  
  178.         There are several uses for this option. First of all, you can use
  179.         it to change the location of the SnoopDos window when it opens, by
  180.         specifying a filename like -zCON:0/0/640/60/SnoopDos) (for a very
  181.         short window). You should always make sure the window is at least 77
  182.         columns wide or the output will look pretty messed up.
  183.  
  184.         You can of course redirect output to a normal AmigaDOS file. You
  185.     would do this if you wanted to keep a permanent record of what hap-
  186.     pened on your system. This could be useful if you allow remote access
  187.     to your Amiga and want a record of what people do during a session.
  188.  
  189.     If you say -z+filename instead of -zfilename, then SnoopDos will
  190.     append information to an existing file, rather than creating a
  191.     new file. This allows you to capture several logs in a single
  192.     file over a period of time. In addition, you can use the AmigaDOS
  193.     TYPE command to display a capture file that is currently being
  194.     written to by SnoopDos if it was opened with -z+; this allows you
  195.     to see the progress of the log to date. See also the -n option.
  196.  
  197.     By default, ANSI colour is disabled when outputting to a file. You
  198.     can re-enable it if you like with the -a option.
  199.  
  200.     -zd This option is similar to -z but it directs output to a debugging
  201.         terminal connected to your serial port in the same manner as
  202.     Enforcer, Mungwall, and other debugging tools.
  203.   
  204.  
  205. THE SNOOPDOS WINDOW
  206.  
  207.     The SnoopDos window is divided into a number of columns, as follows:
  208.  
  209.     Process name
  210.         The name of the process (or CLI command) that is executing the
  211.         DOS call in question. If the DOS call is nested (see Res. below)
  212.         then the process name will be prefixed by '> '.
  213.  
  214.     Func
  215.         The function being executed (Open, Lock or Load). Open is printed
  216.         in white, Lock in orange and Load in black, to allow rows to be
  217.         quickly identifed at a glance. (Of course, if you've changed your
  218.         Preferences, the actual colours may be different.) Other values
  219.         which can appear here are Exec (for Execute), CD (for CurrentDir)
  220.         and Del (for DeleteFile).
  221.  
  222.     Filename
  223.         The name of the file being accessed. Remember that when the `-f'
  224.         option is enabled, this will be prefixed by a `>' character if the
  225.         filename displayed was expanded by SnoopDos to include the current
  226.         directory of the calling process.
  227.  
  228.     Mode
  229.         For Open(), this is OLD if an existing file is being opened or NEW
  230.         if a new file is being opened. For Lock(), this is SHAR if the lock
  231.         is a shared lock (i.e. several processes can access the same file) or
  232.         EXCL if it is an exclusive lock (only this process can access the
  233.         file). It remains empty for LoadSeg().
  234.  
  235.     Res.
  236.         The result of the DOS call. This is either `Okay' in white or
  237.         `Fail' in orange. In general, you learn much more from the `Fail'
  238.         entries (i.e. the things the program tried to find but couldn't).
  239.  
  240.         Occasionally, you may see a `>>>>' appearing here. This happens if
  241.         some other program has also patched DOS library in such a way that
  242.         the function currently being called calls another DOS function
  243.         itself. One such program is Rez, which tries to open a program file
  244.         for reading if you LoadSeg() it. In this case, the `>>>>' indicates
  245.         that DOS calls are being nested. The DOS calls which are nested
  246.         will have the associated process name prefixed by `> ' when they
  247.         are displayed. `> (Done)' is displayed when the top level DOS
  248.         function exits, and the exit status is displayed on the same
  249.         line in the Res. column as normal.
  250.  
  251.     You can type several keys into the SnoopDos window. CTRL-C will terminate
  252.     SnoopDos. CTRL-D will disable monitoring temporarily (and print a brief
  253.     message to that effect); CTRL-E enables it again. Pressing Space or any
  254.     other key will pause the output to the window, as in a CLI window. Press
  255.     BackSpace to continue. Note that if you have the `-w' option enabled and
  256.     you pause the output, all functions for which monitoring is enabled will
  257.     cause the calling process to go to sleep until you restart output again.
  258.  
  259.     When SnoopDos wants to quit, it makes sure that nobody else has patched
  260.     the DOS library after it. If something has, SnoopDos will refuse to exit
  261.     immediately. Instead, it will check approximately every 5 seconds to
  262.     see if it is safe to exit and as soon as it can, it will.
  263.  
  264.  
  265. TRICKS AND TIPS
  266.  
  267.     Some users have been asking for a scrollback facility in the SnoopDos
  268.     window, and also a close gadget. A future version of SnoopDos may
  269.     include a full GUI with these features and much more, but for now,
  270.     you can use the following very kludgey workarounds if you like:
  271.  
  272.     Scroll bar: The freely distributable console handler SPHINX: can
  273.     be used to provide this facility. Use a command line like:
  274.  
  275.         SnoopDos -zSPHINX:////SnoopDos
  276.  
  277.     You can also use the freely distributable CB program (V1.1), though this
  278.     is a little more involved; open a new shell window, run CB, and then
  279.     start SnoopDos with the line:
  280.  
  281.         SnoopDos -z*
  282.  
  283.     This tells SnoopDos to redirect its output to the current CLI window,
  284.     and so it will benefit from CB's scrollback facilities.
  285.  
  286.     CLOSE Gadget: This is even more kludgey, but if you absolutely must
  287.     have one, you can do it under Workbench 2.0 like this. Create a batch
  288.     file called S:Start-SnoopDos containing the following:
  289.  
  290.         SnoopDos -z*
  291.         Ask "Press RETURN or click the close gadget to quit SnoopDos"
  292.         SnoopDos -q
  293.         EndCli >NIL:
  294.  
  295.     Then create a shell alias like this:
  296.  
  297.         Alias Snoop "NewCli con:0/0/640/200/Snoop/CLOSE from s:Start-SnoopDos"
  298.  
  299.     Then when you type Snoop into a Shell window, SnoopDos will start up in
  300.     its own Window and clicking the close gadget in that window will remove
  301.     it. Be warned though; CTRL-C, CTRL-D and CTRL-E will no longer work
  302.     properly, and pressing RETURN will also close the window.
  303.  
  304.     What can I say ... when I have time, I'll write a proper GUI version.
  305.  
  306.  
  307. AUTHOR
  308.  
  309.     Eddy Carroll
  310.  
  311.     Email:     ecarroll@maths.tcd.ie
  312.  
  313.     Phone:     +353-1-287-4566
  314.     Fax:       +353-1-287-5663
  315.  
  316.     Snailmail: The Old Rectory,
  317.                Delgany,
  318.                Co. Wicklow,
  319.            Ireland.
  320.  
  321.  
  322. DISTRIBUTION
  323.  
  324.     SnoopDos may be freely distributed as long as no charge is made other
  325.     than to cover time and copying costs. If you want to include SnoopDos
  326.     as part of a commercial package (somehow I doubt it but it never hurts
  327.     to mention :-) then contact the author listed above. Fred Fish is
  328.     specifically given permission to include SnoopDos in his fine disk
  329.     collection.
  330.